<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>设置起点</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../js/customer.js"></script>
     <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=4082cc7cea44a1f8c926676ce9508fac&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.Geocoder"></script>
     <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>
<body onload="regeocoder()">
<section class="itemgroup p15 mt10" id="inputAddressSection">
</section>
<!--section class="subtitle p15"><button class="btn bottomonebtn" onclick="javascript:save();">提交</button></section-->
<section class="subtitle mt10 p15">常用地址</section>
<section class="itemgroup p15" id="commonAddressSection">
    
</section>

 	<input type="hidden" id="vehiclePriceId" name="vehiclePriceId" value=""/>
     <input type="hidden" id="bookDate" name="bookDate" value=""/>
     <input type="hidden" id="consignName" name="consignName" value=""/>
     <input type="hidden" id="consignMobile" name="consignMobile" value=""/>
     <input type="hidden" id="consignDesc" name="consignDesc" />
     <input type="hidden" id="callType" name="callType" />
     <input type="hidden" id="addrType" name="addrType" >
     <input type="hidden" id="waybillRquirement10" name="waybillRquirement10" />
	 <input type="hidden" id="waybillRquirement20" name="waybillRquirement20" />
	 <input type="hidden" id="waybillRquirement30" name="waybillRquirement30"/>
	 <!-- 终点地址数量 -->
	  <input type="hidden" id="endAddrCount" name="endAddrCount" />
	 <input type="hidden" id="startDistrictCode" name="startDistrictCode" />
	 <input type="hidden" id="startAddr" name="startAddr" />
	 <!--startPCD 起点 省市区-->
	 <input type="hidden" id="startPCD" name="startPCD" />
	 <!-- 起点经纬度 -->
	 <input type="hidden" id="startLocation" name="startLocation"/>
	 
	 <input type="hidden" id="endDistrictCode" name="endDistrictCode" />
	 <input type="hidden" id="endAddr" name="endAddr" />
	 <!--startPCD  省市区-->
	 <input type="hidden" id="endPCD" name="endPCD" />
	 <!-- 终点经纬度 -->
	 <input type="hidden" id="endLocation" name="endLocation" />
	 
	 <!-- 第二终点参数 -->
	 <input type="hidden" id="endDistrictCode1" name="endDistrictCode1" value=""/>
	 <input type="hidden" id="endAddr1" name="endAddr1" value=""/>
	 <!--startPCD  省市区-->
	 <input type="hidden" id="endPCD1" name="endPCD1" />
	 <!-- 终点经纬度 -->
	 <input type="hidden" id="endLocation1" name="endLocation1" />
	 
	 <!-- 第三终点参数 -->
	 <input type="hidden" id="endDistrictCode2" name="endDistrictCode2" />
	 <input type="hidden" id="endAddr2" name="endAddr2" />
	 <!--startPCD  省市区-->
	 <input type="hidden" id="endPCD2" name="endPCD2" />
	 <!-- 终点经纬度 -->
	 <input type="hidden" id="endLocation2" name="endLocation2" />
	 
	 <input type="hidden" id="goodsRemark" name="goodsRemark" />
	 <input type="hidden" id="goodsType" name="goodsType" />
	 <input type="hidden" id="consignNum" name="consignNum" />
	 <input type="hidden" id="goodsTypeName" name="goodsTypeName"/>
	 <input type="hidden" id="customerUuid" name="customerUuid" />
	  <input type="hidden" id="startStreet" name="startStreet" />
	 <input type="hidden" id="startCross" name="startCross" />
	 <input type="hidden" id="startDoorNo" name="startDoorNo" />
	 
	 <input type="hidden" id="endStreet" name="endStreet" />
	 <input type="hidden" id="endCross" name="endCross" />
	 <input type="hidden" id="endDoorNo" name="endDoorNo" />
	 <input type="hidden" id="acceptPersonMobile" name="acceptPersonMobile" />
	 <input type="hidden" id="acceptPersonName" name="acceptPersonName" />
	 
	 <input type="hidden" id="endStreet1" name="endStreet1" />
	 <input type="hidden" id="endCross1" name="endCross1" />
	 <input type="hidden" id="endDoorNo1" name="endDoorNo1" />
	 <input type="hidden" id="acceptPersonMobile1" name="acceptPersonMobile1" />
	 <input type="hidden" id="acceptPersonName1" name="acceptPersonName1" />
	 
	 <input type="hidden" id="endStreet2" name="endStreet2" />
	 <input type="hidden" id="endCross2" name="endCross2" />
	 <input type="hidden" id="endDoorNo2" name="endDoorNo2" />
	 <input type="hidden" id="acceptPersonMobile2" name="acceptPersonMobile2" />
	 <input type="hidden" id="acceptPersonName2" name="acceptPersonName2" />
	 
	  <input type="hidden" id="planLoadTime" name="planLoadTime" />
	 <input type="hidden" id="planUnloadTime" name="planUnloadTime" />
	 <input type="hidden" id="planLoadFee" name="planLoadFee" />
	 <input type="hidden" id="planUnloadFee" name="planUnloadFee" />
	 <input type="hidden" id="planLowSpeedTime" name="planLowSpeedTime" />
	 <input type="hidden" id="planLowSpeedFee" name="planLowSpeedFee" />
	 
	
</body>
<script>
$(function (){
	 //token验证
		checkToken();
	}); 
$(function(){
	//'customerUuid':customerUuid
	var customerUuid=getCookie("customerUuid")
	$("#customerUuid").val(customerUuid);
	var LocString = String(window.document.location.href); 
	var addrType=getCookie("addrType"); 
	
	try{
		delegate.getCurrentLocation();
	}catch(e){
			
	}
	if(addrType=='START_ADDR'){
		 $(document).attr("title","设置起点");	
	}else if(addrType=='END_ADDR'){
		$(document).attr("title","设置终点");
	}else{
		$(document).attr("title","设置中间点");
	}
	
	var endAddrCount=getCookie("endAddrCount"); 
	
	 var url = _global.serverHost +"/consignerOrder/selectAddress.htm";
     var data = {
    	'addrType':addrType,
    	'customerUuid':customerUuid
     };
     _callAjaxRequest(url, data, callBack);

     function callBack(data) {
    	 //读取订单保留数据
    	  cookie2Order(); 
    	  
    	  var inputAddressSection='';
    	  
    	  if(addrType=='START_ADDR'){
    		  var consignName=$("#consignName").val();
    	      	if(consignName==undefined){
    	      		consignName='';
    	      	}
    	       	//inputAddressSection=inputAddressSection+'<a href="javascript:save();">提交</a><div class="inputarea">'
    	       	inputAddressSection=inputAddressSection+'<div class="inputarea">'
    	       	+'<label class="inputname">联系人</label>'
    	       	+'<label class="inputform">'
    	       	+'<i class="iconfont wipe">&#xe614;</i>'
    	       	+'<input class="formstyle w100" type="text" placeholder="必填" id="consignName" name="consignName" value="'+consignName+'"/>'
    	       	+'</label>'
    	       	+' </div>';
    	       	var consignMobile=$("#consignMobile").val();
    	       	if(consignMobile==undefined){
    	       		consignMobile='';
    	      	}
    	       	inputAddressSection=inputAddressSection+'<div class="inputarea">'
    	       	+'<label class="inputname">联系电话</label>'
    	       	+'<label class="inputform">'
    	       	+' <i class="iconfont wipe">&#xe614;</i>'
    	       	+'<input class="formstyle w100" type="text" placeholder="必填"  id="consignMobile" name="consignMobile" value="'+consignMobile+'"/>'
    	       	+' </label>'
    	       	+'</div>';
    	    	  
    	    	  inputAddressSection=inputAddressSection+'<div class="inputarea" style="display:none;">'
    	    	  +'<label class="inputname">详细地址</label>'
    	    	  +'<label class="inputform">'
    	    	  +' <i class="iconfont wipe">&#xe614;</i>';
    	    	  var startAddr=$("#startAddr").val();
    	    	  
    		  //inputAddressSection=inputAddressSection+'<input class="formstyle w100" type="text" placeholder="小区、大厦、街道、或商圈" ' +' id="tipinput" name="address" value="'+startAddr+'" autocomplete="off"/>';
    	  }else{
    		  if(endAddrCount==1){
    			  
    			  
    			  var consignName=$("#acceptPersonName").val();
    		      	if(consignName==undefined){
    		      		consignName='';
    		      	}
    		       	//inputAddressSection=inputAddressSection+'<a href="javascript:save();">提交</a><div class="inputarea">'
    	       		inputAddressSection=inputAddressSection+'<div class="inputarea">'
    		       	+'<label class="inputname">联系人</label>'
    		       	+'<label class="inputform">'
    		       	+'<i class="iconfont wipe">&#xe614;</i>'
    		       	+'<input class="formstyle w100" type="text" placeholder="必填" id="acceptPersonName" name="acceptPersonName" value="'+consignName+'"/>'
    		       	+'</label>'
    		       	+' </div>';
    		       	var consignMobile=$("#acceptPersonMobile").val();
    		       	if(consignMobile==undefined){
    		       		consignMobile='';
    		      	}
    		       	inputAddressSection=inputAddressSection+'<div class="inputarea">'
    		       	+'<label class="inputname">联系电话</label>'
    		       	+'<label class="inputform">'
    		       	+' <i class="iconfont wipe">&#xe614;</i>'
    		       	+'<input class="formstyle w100" type="text" placeholder="必填"  id="acceptPersonMobile" name="acceptPersonMobile" value="'+consignMobile+'"/>'
    		       	+' </label>'
    		       	+'</div>';
    		    	  
    		    	  inputAddressSection=inputAddressSection+'<div class="inputarea" style="display:none;">'
    		    	  +'<label class="inputname">详细地址</label>'
    		    	  +'<label class="inputform">'
    		    	  +' <i class="iconfont wipe">&#xe614;</i>';
    			  
    			  
    			  
    			  var endAddr=$("#endAddr").val();
    			  //inputAddressSection=inputAddressSection+'<input class="formstyle w100" type="text" placeholder="小区、大厦、街道、或商圈" '+'id="tipinput" name="address" value="'+endAddr+'"  autocomplete="off"/>';
    		  }else if(endAddrCount==2){
    			  
    			  var consignName=$("#acceptPersonName1").val();
  		      	if(consignName==undefined){
  		      		consignName='';
  		      	}
  		       	//inputAddressSection=inputAddressSection+'<a href="javascript:save();">提交</a><div class="inputarea">'
    	       	inputAddressSection=inputAddressSection+'<div class="inputarea">'
  		       	+'<label class="inputname">联系人</label>'
  		       	+'<label class="inputform">'
  		       	+'<i class="iconfont wipe">&#xe614;</i>'
  		       	+'<input class="formstyle w100" type="text" placeholder="必填" id="acceptPersonName1" name="acceptPersonName1" value="'+consignName+'"/>'
  		       	+'</label>'
  		       	+' </div>';
  		       	var consignMobile=$("#acceptPersonMobile1").val();
  		       	if(consignMobile==undefined){
  		       		consignMobile='';
  		      	}
  		       	inputAddressSection=inputAddressSection+'<div class="inputarea">'
  		       	+'<label class="inputname">联系电话</label>'
  		       	+'<label class="inputform">'
  		       	+' <i class="iconfont wipe">&#xe614;</i>'
  		       	+'<input class="formstyle w100" type="text" placeholder="必填"  id="acceptPersonMobile1" name="acceptPersonMobile1" value="'+consignMobile+'"/>'
  		       	+' </label>'
  		       	+'</div>';
  		    	  
  		    	  inputAddressSection=inputAddressSection+'<div class="inputarea" style="display:none;">'
  		    	  +'<label class="inputname">详细地址</label>'
  		    	  +'<label class="inputform">'
  		    	  +' <i class="iconfont wipe">&#xe614;</i>';
  		    	  
  		    	  
    			  var endAddr1=$("#endAddr1").val();
    			  //inputAddressSection=inputAddressSection+'<input class="formstyle w100" type="text" placeholder="小区、大厦、街道、或商圈" '+' id="tipinput" name="address" value="'+endAddr1+'"  autocomplete="off"/>';
    		  }else if(endAddrCount==3){
    			  
    			  var consignName=$("#acceptPersonName2").val();
    		      	if(consignName==undefined){
    		      		consignName='';
    		      	}
    		       	//inputAddressSection=inputAddressSection+'<a href="javascript:save();">提交</a><div class="inputarea">'
    	       		inputAddressSection=inputAddressSection+'<div class="inputarea">'
    		       	+'<label class="inputname">联系人</label>'
    		       	+'<label class="inputform">'
    		       	+'<i class="iconfont wipe">&#xe614;</i>'
    		       	+'<input class="formstyle w100" type="text" placeholder="必填" id="acceptPersonName2" name="acceptPersonName2" value="'+consignName+'"/>'
    		       	+'</label>'
    		       	+' </div>';
    		       	var consignMobile=$("#acceptPersonMobile2").val();
    		       	if(consignMobile==undefined){
    		       		consignMobile='';
    		      	}
    		       	inputAddressSection=inputAddressSection+'<div class="inputarea">'
    		       	+'<label class="inputname">联系电话</label>'
    		       	+'<label class="inputform">'
    		       	+' <i class="iconfont wipe">&#xe614;</i>'
    		       	+'<input class="formstyle w100" type="text" placeholder="必填"  id="acceptPersonMobile2" name="acceptPersonMobile2" value="'+consignMobile+'"/>'
    		       	+' </label>'
    		       	+'</div>';
    		    	  
    		    	  inputAddressSection=inputAddressSection+'<div class="inputarea" style="display:none;">'
    		    	  +'<label class="inputname">详细地址</label>'
    		    	  +'<label class="inputform">'
    		    	  +' <i class="iconfont wipe">&#xe614;</i>';
    		    	  
    		    	  
    			  var endAddr2=$("#endAddr2").val();
    			  //inputAddressSection=inputAddressSection+' <input class="formstyle w100" type="text" placeholder="小区、大厦、街道、或商圈" '+' id="tipinput" name="address" value="'+endAddr2+'"  autocomplete="off"/>';
    		  }
    	  }
    	  inputAddressSection=inputAddressSection+' </label>'
     	 +'</div>';
     	 
     	 
     	if(addrType=='START_ADDR'){
     		
     		var startAddr=$("#startAddr").val();
     		var startStreet=$("#startStreet").val();
     		var startCross=$("#startCross").val();
     		var startDoorNo=$("#startDoorNo").val();
     		
     		if(startStreet==null || startStreet==''){
     			startStreet='&nbsp; ';
     		}
     		var startAddrStr;
     		if(startAddr==null || startAddr==''){
     			startAddr='&nbsp; ';
     			startAddrStr='<input class="formstyle w100" type="text" placeholder="小区、大厦、街道、或商圈" '+' id="tipinput" name="address" autocomplete="off"/>';
     		}else{
     			startAddrStr='<input class="formstyle w100" type="text" placeholder="小区、大厦、街道、或商圈" '+' id="tipinput" name="address" value="'+startAddr+'"  autocomplete="off"/>';
     		}
     		
     		inputAddressSection=inputAddressSection+'<div class="inputarea">'
         	+'<label class="inputname_ad">详细地址</label>'
         	+'<label class="inputform">'
         	+'<i class="iconfont wipe">&#xe6db;</i>'
         	+'<span id="startAddrDesc" style="display:none;">'+startAddr+'</span>'
         	+startAddrStr
         	+'<span class="gray font12 lh20" id="startStreetDesc">'+startStreet+'</span>'
         	+'</label>'
         	+' </div>';
     		inputAddressSection=inputAddressSection+'<div class="inputarea">'
         	+'<label class="inputname">门牌号</label>'
         	+'<label class="inputform">'
         	+'<i class="iconfont wipe">&#xe614;</i>'
         	+'<input class="formstyle w100" id="startDoorNo" name="startDoorNo" value="'+startDoorNo+'" type="text"  placeholder="例:5号楼203室"/>'
         	+'</label>'
         	+'</div>';
        
        
         	inputAddressSection=inputAddressSection+'<div class="inputarea">'
         	+'<label class="inputname">交叉路口</label>'
         	+'<label class="inputform">'
         	+'<i class="iconfont wipe">&#xe614;</i>'
         	+'<input class="formstyle w100" type="text"  id="startCross" name="startCross" value="'+startCross+'" placeholder="请输入交叉路口"/>'
         	+'</label>'
         	+' </div>';
     	}else{
     		
     		var endAddr=$("#endAddr").val();
     		var endStreet=$("#endStreet").val();
     		var endCross=$("#endCross").val();
     		var endDoorNo=$("#endDoorNo").val();
     		var empNo="";
     		 if(endAddrCount==1){
     			 
     		 }else if(endAddrCount==2){
     			 endAddr=$("#endAddr1").val();
         		 endStreet=$("#endStreet1").val();
         		 endCross=$("#endCross1").val();
         		 endDoorNo=$("#endDoorNo1").val();
         		empNo='1';
     		 }else{
     			endAddr=$("#endAddr2").val();
        		 endStreet=$("#endStreet2").val();
        		 endCross=$("#endCross2").val();
        		 endDoorNo=$("#endDoorNo2").val();
        		 empNo='2';
     		 }
     		    var endAddrStr;
         		if(endStreet==null || endStreet==''){
         			endStreet='&nbsp; ';
         		}
         		if(endAddr==null || endAddr==''){
         			endAddr='&nbsp; ';
         			endAddrStr='<input class="formstyle w100" type="text" placeholder="小区、大厦、街道、或商圈" '+' id="tipinput" name="address" autocomplete="off"/>';
         		}else{
         			endAddrStr='<input class="formstyle w100" type="text" placeholder="小区、大厦、街道、或商圈" '+' id="tipinput" name="address" value="'+endAddr+'"  autocomplete="off"/>';
         		}
         		inputAddressSection=inputAddressSection+'<div class="inputarea">'
             	+'<label class="inputname_ad">详细地址</label>'
             	+'<label class="inputform">'
             	+'<i class="iconfont wipe">&#xe6db;</i>'
             	+'<span id="endAddrDesc" style="display:none;">'+endAddr+'</span>'
             	+endAddrStr
             	+'<span class="gray font12 lh20" id="endStreetDesc">'+endStreet+'</span>'
             	+'</label>'
             	+' </div>';
         		inputAddressSection=inputAddressSection+'<div class="inputarea">'
             	+'<label class="inputname">门牌号</label>'
             	+'<label class="inputform">'
             	+'<i class="iconfont wipe">&#xe614;</i>'
             	+'<input class="formstyle w100" id="endDoorNo'+empNo+'" name="endDoorNo'+empNo+'" value="'+endDoorNo+'" type="text"  placeholder="例:5号楼203室"/>'
             	+'</label>'
             	+'</div>';
            
            
             	inputAddressSection=inputAddressSection+'<div class="inputarea">'
             	+'<label class="inputname">交叉路口</label>'
             	+'<label class="inputform">'
             	+'<i class="iconfont wipe">&#xe614;</i>'
             	+'<input class="formstyle w100" type="text"  id="endCross'+empNo+'" name="endCross'+empNo+'" value="'+endCross+'" placeholder="请输入交叉路口"/>'
             	+'</label>'
             	+' </div>';
     			 
     		
     	}
     	 
     	
     	
    	
      
    	  $("#inputAddressSection").html(inputAddressSection);
    	  
    	  var commonAddressSection="";
    	  var commonAddressList=data.commonAddressList;
    	  if(commonAddressList==null || commonAddressList.length<1){
    	  }else{
    		  for(var i=0;i<commonAddressList.length;i++){
    			  if(commonAddressList[i].consignName==undefined){
    				  commonAddressList[i].consignName='';
    			  }
    			  if(addrType=='START_ADDR'){
    				  commonAddressSection=commonAddressSection+'<div class="twoitem" onclick="selectCommon(\''+addrType+'\',\''+commonAddressList[i].startPCD+'\',\''+commonAddressList[i].startAddr+'\',\''+commonAddressList[i].startLocation+ '\',\''+commonAddressList[i].consignName+'\',\''+commonAddressList[i].consignMobile
    						  +'\',\''+commonAddressList[i].startStreet+'\',\''+commonAddressList[i].startDoorNo+'\',\''+commonAddressList[i].startCross+ '\')">'
    				  +'<label class="itemname">'
    				  +commonAddressList[i].startAddr 
    	    		        	+' </label>'
    	    		        	+' <label class="itemsubname">'+commonAddressList[i].consignName+ commonAddressList[i].consignMobile +'</label>'
    	    		        	+'</div> ';
    			  }else{
    				  commonAddressSection=commonAddressSection+'<div class="twoitem"  onclick="selectCommon(\''+addrType+'\',\''+commonAddressList[i].endPCD+'\',\''+commonAddressList[i].endAddr +'\',\''+commonAddressList[i].endLocation +'\',\''+commonAddressList[i].acceptPersonName +'\',\''+commonAddressList[i].acceptPersonMobile 
    						  +'\',\''+commonAddressList[i].endStreet+'\',\''+commonAddressList[i].endDoorNo+'\',\''+commonAddressList[i].endCross+'\')">'
    	    	       +' <label class="itemname">'
    	    	      + commonAddressList[i].endAddr
    	    	       +'</label>'
    	    	       +'<label class="itemsubname">'+commonAddressList[i].acceptPersonName +commonAddressList[i].acceptPersonMobile+'</label>'
    	    	       +' </div>';
    			  }
    			 
   			  }
    			 
    	 }
    	  $("#commonAddressSection").html(commonAddressSection);
    	  
    	  //输入提示
    	    var autoOptions = {
    	        input: "tipinput"
    	    };
    	    var auto = new AMap.Autocomplete(autoOptions);
    	    var placeSearch = new AMap.PlaceSearch();  //构造地点查询类
    	    AMap.event.addListener(auto, "select", select);//注册监听，当选中某条记录时会触发
    	    function select(e) {
    	        placeSearch.setCity(e.poi.adcode);
    			//关键字查询查询
    	        placeSearch.search(e.poi.name,function(status, result){
    					if (status === 'complete' && result.info === 'OK') {
    					//result.poiList.pois[0].name
    					     /*  var test = e.poi;
    						var iS='';
    						for(var i in test ){
    							iS=iS+'<br/>\n' +i+" : "+test[i];
    						}
    						alert(iS);    */
    						
    						var addrType=$("#addrType").val();
    						if(addrType==='START_ADDR'){
    							$("#startDistrictCode").val(e.poi.adcode);
    							$("#startAddr").val(e.poi.name);
    							$("#startPCD").val(e.poi.district);
    							$("#startLocation").val(e.poi.location);
    							$("#startAddrDesc").html(e.poi.name);
    							$("#startStreetDesc").html(e.poi.address);
    							$("#startStreet").val(e.poi.address);
    							
    						}
    						if(addrType==='END_ADDR'){
    							
    							var endAddrCount=$("#endAddrCount").val()*1;
    							endAddrCount--;
    							if(endAddrCount==0){
    								endAddrCount='';
    							}
    							$("#endDistrictCode"+endAddrCount).val(e.poi.adcode);
    							$("#endAddr"+endAddrCount).val(e.poi.name);
    							$("#endPCD"+endAddrCount).val(e.poi.district);
    							$("#endLocation"+endAddrCount).val(e.poi.location);
    							$("#endAddrDesc").html(e.poi.name);
    							$("#endStreetDesc").html(e.poi.address);
    							$("#endStreet"+endAddrCount).val(e.poi.address);
    						}
    					}
    				});  
    	    }
    	 
    }
   });
   

function selectCommon(addrType,pdc,addr,location,consignName,consignMobile,street,doorNo,cross){
	var endAddrCount=$("#endAddrCount").val();
	
	if(endAddrCount=='1'){
		endAddrCount="";
	}else{
		endAddrCount=endAddrCount-1;
	}
	if(addrType=='START_ADDR'){
		$("#startAddr").val(addr);
		$("#startPCD").val(pdc);
		$("#startLocation").val(location);
		$("#consignName").val(consignName);
		$("#consignMobile").val(consignMobile);
		$("#startStreet").val(street);
		$("#startDoorNo").val(doorNo);
		$("#startCross").val(cross);
		
	}else{
		$("#endAddr"+endAddrCount).val(addr);
		$("#endPCD"+endAddrCount).val(pdc);
		$("#endLocation"+endAddrCount).val(location);
		$("#acceptPersonName"+endAddrCount).val(consignName);
		$("#acceptPersonMobile"+endAddrCount).val(consignMobile);
		
		$("#endStreet").val(street);
		$("#endDoorNo").val(doorNo);
		$("#endCross").val(cross);
	}
	save();
}

function save(){
	//更新订单信息
	order2Cookie();
	
	var endAddrCount=$("#endAddrCount").val();
	//终点
	if(endAddrCount!=null && endAddrCount!=''){
			 var endStreet='';
			 var endCross='';
			 var acceptPersonMobile='';
			 var acceptPersonName='';
			 if(endAddrCount*1==1){
				 acceptPersonMobile=$("#acceptPersonMobile").val();
				 acceptPersonName=$("#acceptPersonName").val();
				 endStreet=$("#endStreet").val();
				 endCross=$("#endCross").val();
			 }else{
				 acceptPersonMobile=$("#acceptPersonMobile"+endAddrCount).val();
				 acceptPersonName=$("#acceptPersonName"+endAddrCount).val();
				 endStreet=$("#endStreet"+endAddrCount).val();
				 endCross=$("#endCross"+endAddrCount).val();
			 }
			 
			 if(acceptPersonName==null || acceptPersonName==''){
				 alert("联系人不能为空");
				 return;
			 }
			 if(acceptPersonMobile==null || acceptPersonMobile==''){
				 alert("联系电话不能为空");
				 return;
			 }
			 if(endStreet==null || endStreet==''){
				 alert("详细地址不能为空");
				 return;
			 }
			 
			 if(endCross==null || endCross==''){
				 alert("交叉路口信息不能为空");
				 return;
			 }
		
	}
	
	
	/* var url="${pageContext.request.contextPath}/consignerOrder/submitAddress.htm";
	document.forms[0].action = url;
	document.forms[0].submit(); */
	  //order2Cookie();
	
	
	  var callType=$("#callType").val();
	  if(callType=='NOW'){
		  window.location.href="../"+_global.custNowOrderUrl;
	  }else{
		  window.location.href="../"+_global.custBookOrderUrl;
	  }
}


</script>

<script type="text/javascript">

$(function (){
	var lnglatXY = [121.319308, 31.240986]; //已知点坐标
	//如果获取不到的地址的话，默认一个经纬度
	var llon='121.319308';
	var llat='31.240986';
	 try{
		var positionStr=delegate.getCurrentLocation();
		if(positionStr!=undefined && positionStr!=null){
		//'{lon=101,lat=102}'转化为'{lon:101,lat:102}'
			positionStr=positionStr.replace("=",":").replace("=",":");
		//string 转化为json
			var positionObj=eval('(' + positionStr + ')');
			 llon=positionObj.lon;
			 llat=positionObj.lat;
			if(llon!=undefined && llon != null && llon!='' ){
				lnglatXY = [llon, llat];
			}
		}
	}catch (e) 
	{ 
		lnglatXY = [121.319308, 31.240986]; //已知点坐标
		//throw new Error(11,) 
		console.log("delegate.getCurrentLocation()不能读取当前地址经纬度");
	}  
	
	
	
	var startAddr=$("#startAddr").val();
	
	
	if(startAddr!=undefined && startAddr !=null && startAddr !=''){
		
	  return false;	
	}
    var geocoder = new AMap.Geocoder({
        radius: 1000,
        extensions: "all"
    });        
    geocoder.getAddress(lnglatXY, function(status, result) {
        if (status === 'complete' && result.info === 'OK') {
            geocoder_CallBack(result);
          
          var a = result.regeocode.addressComponent;
        /*  alert(result.regeocode.formattedAddress);
						var iS='';
						for(var i in test ){
							iS=iS+'<br/>\n' +i+" : "+test[i];
						}
						alert(iS); */
          
          var aa=result.regeocode.pois;
         /*  alert(aa[0].name); */
          
          
           $("#startDistrictCode").val(a.adcode);
			$("#startAddr").val(aa[0].name);
			$("#tipinput").val(aa[0].name);
			$("#startPCD").val(a.province+a.city+a.district);
			$("#startLocation").val(llon+','+llat);
			$("#startAddrDesc").html(aa[0].name);
			$("#startStreetDesc").html(a.street+a.streetNumber);
			$("#startStreet").val(a.street+a.streetNumber); 
        }
    });  
	
})

function regeocoder() {  //逆地理编码
	
      

}
function geocoder_CallBack(data) {
   
}

</script>
</html>